#ifndef __MYSQLCONNECTOR_H__
#define __MYSQLCONNECTOR_H__

#include <mysql/mysql.h>
#include <string>
#include <memory>

using std::string;
using std::unique_ptr;

class MySQLConnector {
public:
    static MySQLConnector* getInstance();

    /* MYSQL_RES* executeQuery(const string &query); */
    unique_ptr<MYSQL_RES, void(*)(MYSQL_RES*)> executeQuery(const string &query);

private:
    MySQLConnector();
    ~MySQLConnector();

    static void init();
    static void destroy();

private:
    static MySQLConnector* _pInstance;
    static pthread_once_t _once;
    MYSQL* _con;
};

#endif

